<?php

App::uses('AppModel', 'Model');

class Transaction extends AppModel {

    public $name = 'Transaction';
    
    public $hasMany = array(
        'TransactionBankDetail' => array(
            'className' => 'TransactionBankDetail',
            'foreignKey' => 'transaction_id',
            'conditions' => '',
            'fields' => '',
            'order' => ''
        ),
        'TransactionItem' => array(
            'className' => 'TransactionItem',
            'foreignKey' => 'transaction_id',
            'conditions' => '',
            'fields' => '',
            'order' => ''
        ),
        'ServiceCharge' => array(
            'className' => 'ServiceCharge',
            'foreignKey' => 'transaction_id',
            'conditions' => '',
            'fields' => '',
            'order' => ''
        )
    );

    public $hasOne = array(
        'BankCreditAuthorization' => array(
            'className' => 'BankCreditAuthorization',
            'foreignKey' => 'transaction_id',
            'conditions' => '',
            'fields' => '',
            'order' => ''
        ),
        'BankReversalAuthorization' => array(
            'className' => 'BankReversalAuthorization',
            'foreignKey' => 'transaction_id',
            'conditions' => '',
            'fields' => '',
            'order' => ''
        )
    );
    
    public $belongsTo = array(
        'StudentUser' => array(
            'className' => 'StudentUser',
            'foreignKey' => 'student_user_id',
            'conditions' => '',
            'fields' => '',
            'order' => ''
        ),
        'AcademicSession' => array(
            'className' => 'AcademicSession',
            'foreignKey' => 'academic_session_id',
            'conditions' => '',
            'fields' => '',
            'order' => ''
        ),
        'BankUser' => array(
            'className' => 'BankUser',
            'foreignKey' => 'bank_user_id',
            'conditions' => '',
            'fields' => '',
            'order' => ''
        ),
        'Bank' => array(
            'className' => 'Bank',
            'foreignKey' => 'bank_id',
            'conditions' => '',
            'fields' => '',
            'order' => ''
        )
    );


    public function save($data = null,$validate = true, $fieldList = array()) {
        $s = $this->sanitize($data);
        return parent::save($s);
    }
}